import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import tabBar from '@/utils/tabbar.js'

const store = new Vuex.Store({
    state: {
        that: null,
        wx_token: '',
        tabBarList: [],
        roleId: undefined,
        checkedValue: 0,
        hasLogin: false,
        userInfo: {}
    },

    mutations: {
        setUserInfo(state, data) {
            state.userInfo = data;
        },
        setCheckedValue(state, data) {
            state.checkedValue = data;
        },
        setRoleId(state, data) {
            uni.setStorage({
                key: 'roleId',
                data: data        
            });
            state.roleId = data
             
            if (data === 1) {
                state.checkedValue = 6;
                state.tabBarList = tabBar['summaryTabBar']
                uni.setStorage({
                    key: 'tabBarList',
                    data: tabBar['summaryTabBar']        
                });
            }
            if (data === 2) {
                state.checkedValue = 0;
                state.tabBarList = tabBar['leaderTabBar']
                uni.setStorage({
                    key: 'tabBarList',
                    data: tabBar['leaderTabBar']        
                });
            }
            if (data === 3) {
                state.checkedValue = 3;
                state.tabBarList = tabBar['documentTabBar']
                uni.setStorage({
                    key: 'tabBarList',
                    data: tabBar['documentTabBar']       
                });
            }
            //uni.setStorage('tabBarList', tabBar[data])
           
        }
    },
    actions: {

    }
})

export default store